package com.example.controller;

import com.example.pojo.TeacherCalling;
import com.example.pojo.TeachingCallingDetail;
import com.example.service.CallingService;
import com.example.utils.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@Api("点名管理接口")
public class CallingController {
    @Autowired
    private CallingService callingService;

    //添加
    @PostMapping("/calling")
    public Result createCalling(@RequestBody TeacherCalling teacherCalling){
        callingService.create(teacherCalling);
        return Result.success();
    }

    //编辑
    @PutMapping("/calling")
    public Result updateCalling(@RequestBody TeacherCalling teacherCalling){
        callingService.update(teacherCalling);
        return Result.success();
    }

    //查看
    @GetMapping("/calling")
    public Result queryCalling(@RequestParam Integer id){
        TeacherCalling teacherCalling = callingService.query(id);
        return Result.success(teacherCalling);
    }

    //点名细节
    @PostMapping("/calling/detail")
    public Result addDetail(@RequestBody TeachingCallingDetail teachingCallingDetail){
        callingService.addCallingDetail(teachingCallingDetail);
        return Result.success();
    }
}
